const ENV = import.meta.env

import { defineStore, StoreDefinition } from 'pinia'
import { HomeAction, HomeGetter, HomeState } from './types'

export const homeStore: StoreDefinition<'home', HomeState, HomeGetter, HomeAction> = defineStore('home', {
    state: (): HomeState => ({
        APP_NAME: ENV.VITE_APP_NAME as string,
        systemLang: ENV.VITE_SYSTEM_LANG as 'en' | 'zh_cn',
        appStyle: 'light',
        isFoldMenuModule: false,
    }),
    getters: {
        getAppStyle(state: HomeState) {
            return state.appStyle
        }
    },
    actions: {
        setAppName(payload: string) {
            this.APP_NAME = payload
        }
    }
})